package servlets;

import java.io.IOException;
import java.io.PrintWriter;

//import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Start
 */
@WebServlet("/Start")
public class Start extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public Start() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		if (request.getParameter("weiter") != null
				&& request.getParameter("weiter").equals("ja")) {
			/*RequestDispatcher rd = getServletContext().getRequestDispatcher("/Ziel");
			// Request Erweiterung mit Attributen:
			request.setAttribute("mode", "Jumpsuit");
			rd.forward(request, response);*/
			
			// Weiterleitung mit Hilfe des Browsers
			response.sendRedirect("../Weiterleitung/Ziel");
		} else {
			response.setContentType("text/html");
			PrintWriter out = response.getWriter();
			out.println("<h1>Start</h1>" +
					"<a href=\"../Weiterleitung/Start\">Los ohne Parameter</a><br /><br />"
					+"<a href=\"../Weiterleitung/Start?weiter=ja\">Los mit Parameter</a>");
		}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
